package com.main.modulemysql.service.impl;

import com.main.modulemysql.entity.HjzkFaultFind;
import com.main.modulemysql.service.IChartIndexService;
import com.main.modulemysql.service.IEquipmentService;
import com.main.modulemysql.service.IEquipmentsCategoryService;
import com.main.modulemysql.service.IHjzkFaultFindService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: IceZhang
 * @Date: 2018/8/7 14:31
 * @Description:
 */
@Service
public class ChartInexServiceImpl implements IChartIndexService {

    @Autowired
    IEquipmentService iEquipmentService;
    @Autowired
    IEquipmentsCategoryService iEquipmentsCategoryService;

    @Autowired
    IHjzkFaultFindService iHjzkFaultFindService;

    @Override
    public Map<String, Object> getFacilityTarget(@Param("facilityCode") String facilityCode) {

        HashMap<String, Object> resultMap = new HashMap<>();

        HashMap<String, Object> facilitiesTarget = new HashMap<>();
        Integer allEquipCount = iEquipmentService.getEquipmentCountByFacilityCode(facilityCode);
        Integer allFaultCount = iEquipmentService.getFaultEquipmentCountByFacilityCode(facilityCode);
        facilitiesTarget.put("faultCount",allFaultCount);
        facilitiesTarget.put("equipCount",allEquipCount);
        resultMap.put("facilitiesTarget",facilitiesTarget);

        List<HjzkFaultFind> faultListByFacilityCode = iHjzkFaultFindService.getFaultListByFacilityCode(facilityCode);
        resultMap.put("faultDetailList",faultListByFacilityCode);

        return resultMap;
    }

    @Override
    public Map<String, Object> getSingleTarget(String facilityCode) {
        HashMap<String, Object> resultMap = new HashMap<>();

        HashMap<String, Object> facilitiesTarget = new HashMap<>();
        Integer allEquipCount = iEquipmentService.getEquipmentCountByFacilityCode(facilityCode);
        Integer allFaultCount = iEquipmentService.getFaultEquipmentCountByFacilityCode(facilityCode);
        facilitiesTarget.put("faultCount",allFaultCount);
        facilitiesTarget.put("equipCount",allEquipCount);
        resultMap.put("facilitiesTarget",facilitiesTarget);
        return resultMap;
    }


}